PROJECT(glew C)

SET(TARGET_LIB glew)

find_package(OpenGL)
SET(GLEW_PUBLIC_HEADERS
	${GLEW_SOURCE_DIR}/include/GL/glew.h
	${GLEW_SOURCE_DIR}/include/GL/glxew.h
	${GLEW_SOURCE_DIR}/include/GL/wglew.h
)

SET(GLEW_SRCS
	${GLEW_SOURCE_DIR}/src/glew.c
	#${GLEW_SOURCE_DIR}/src/glewinfo.c
	#${GLEW_SOURCE_DIR}/src/visualinfo.c
)

# Dependent include files
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR})

#ADD_DEFINITIONS(-DBUILDING_LIBCURL -DUSE_WIN32_LDAP)

IF(MSVC)
	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4133 /wd4554 /wd4996 /wd4715")
	ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
	SET(CMAKE_DEBUG_POSTFIX "d")
ENDIF(MSVC)

IF(MINGW)
	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
ENDIF(MINGW)

ADD_LIBRARY(${TARGET_LIB}  ${GLEW_SRCS} ${GLEW_PUBLIC_HEADERS} ${GLEW_PRIVATE_HEADERS})

target_include_directories(${TARGET_LIB} PRIVATE ${GLEW_SOURCE_DIR}/include)
target_include_directories(${TARGET_LIB} PRIVATE ${GLEW_SOURCE_DIR}/lib)

IF(MSVC)
	TARGET_LINK_LIBRARIES(${TARGET_LIB} ${OPENGL_LIBRARIES})
ENDIF(MSVC)

# Runtime equals DLL-files
# Archive equals static libraries
# Library equals module libraries
IF(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
	install(TARGETS ${TARGET_LIB}
		RUNTIME DESTINATION ${EXECUTABLE_OUTPUT_PATH}
		LIBRARY DESTINATION ${LIBRARY_OUTPUT_PATH}
		ARCHIVE DESTINATION ${ARCHIVE_OUTPUT_PATH})
ENDIF()
IF(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
	install(FILES ${CURL_PUBLIC_HEADERS} DESTINATION ${INCLUDE_OUTPUT_PATH}/glew)
ENDIF()
